Rich text formatting on an attribute to create hyperlinks

I have an attribute in a module that has text. I want to use that text as identifiers and replace the text with a hyperlink.

Attribute

  • Attr1
  • Attr2
  • Attr3
  • Attr4

becomes

The DXL I've tried for that is:

// Module m
// Object o both declared

string hyperlink = "https://website.com/"
string new_link = ""
string new_link_with_RTF = ""

for o in m do {
    if (o."Attribute" "" != "") {
        new_link = hyperlink "" o."Attribute" "" "" new_link ""
        new_link_with_RTF = "{\\\\field{\\\\*\\\\fldinst{HYPERLINK \\\"" "" new_link "" ""\"}}{\\\\fldrslt{\\\\ul\\\\cf1 " "" o."SW Implementation Test" "" "}}}"
        o."Attribute" = new_link_with_RTF ""
        displayRich new_link_with_RTF o."Attribute"
        
    }
}

But no variation of this has worked, as displayRich seems to only work on layout DXLs. Is there a way that I can insert RTF code into an attribute and then override that attribute with RTF formatting? Or do I have to use a layout DXL to do this?


irvinshalom - Fri Feb 09 18:53:21 EST 2018

Re: Rich text formatting on an attribute to create hyperlinks
XiaoXingLu - Sun Feb 11 23:30:59 EST 2018

I suppose you can assgin o."Attribute"  with richText. Below is an example and you may need adjust it. Hope it helps.

Module m=current
Object o
string hyperlink = "https://website.com/"
string new_link = ""
string new_link_with_RTF = ""

for o in m do {
    if (o."Attribute" "" != "") {
    print o."Attribute" ""
        new_link = hyperlink "" o."Attribute" "" "" new_link ""
        o."Attribute" =richText("{\\\\field{\\\\*\\\\fldinst{HYPERLINK \\\"" "" new_link "" ""\"}}{\\\\fldrslt{\\\\ul\\\\cf1 " ""  "" "}}}")      
    }
}